package jwt

import (
	"fmt"

	"github.com/golang-jwt/jwt/v5"
	"time"
)

type MyCustomClaims struct {
	UserId uint `json:"userId"`
	jwt.RegisteredClaims
}

func AuthJwt(userId uint, duration time.Duration, JWT_Auth string) string {
	// Create claims while leaving out some of the optional fields
	claims := MyCustomClaims{
		userId,
		jwt.RegisteredClaims{
			// Also fixed dates can be used for the NumericDate
			ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 1)),
		},
	}

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
	ss, err := token.SignedString([]byte(JWT_Auth))
	fmt.Println(ss, err)
	return ss
}
